#!/bin/bash

rm -f tb_cddtl_cust_label_tmp.ddl
rm -f tb_cddtl_cust_label.ddl

for tmp in {1..9}
do 
echo "
create table tb_cddtl_cust_label_tmp_000$tmp(
  task_id character varying(128) not null,
  job_zone_no numeric(9,0) not null,
  temp_record_no numeric(12,0) not null,
  data_date character varying(8) not null,
  cust_no character varying(14) not null,
  cust_label_cd character varying(2000) not null,
  valid_status_code character(1) not null,
  is_skipped numeric(1,0),
  primary key(task_id,job_zone_no,temp_record_no)
);

" >> tb_cddtl_cust_label_tmp.ddl

echo "
create table tb_cddtl_cust_label_000$tmp(
  cust_no character varying(14) not null,
  new_core_cust_label character varying(2000) not null,
  data_date character varying(8) not null,
  zone_val character varying(50) not null,
  create_stamp timestamp(3) without time zone not null,
  last_mod_stamp timestamp(3) without time zone not null,
  optimist_lock_ver_no numeric(9,0),
  primary key(cust_no)
);

" >> tb_cddtl_cust_label.ddl
done

for tmp in {10..64}
do
echo "
create table tb_cddtl_cust_label_tmp_00$tmp(
  task_id character varying(128) not null,
  job_zone_no numeric(9,0) not null,
  temp_record_no numeric(12,0) not null,
  data_date character varying(8) not null,
  cust_no character varying(14) not null,
  cust_label_cd character varying(2000) not null,
  valid_status_code character(1) not null,
  is_skipped numeric(1,0),
  primary key(task_id,job_zone_no,temp_record_no)
);

" >> tb_cddtl_cust_label_tmp.ddl

echo "
create table tb_cddtl_cust_label_00$tmp(
  cust_no character varying(14) not null,
  new_core_cust_label character varying(2000) not null,
  data_date character varying(8) not null,
  zone_val character varying(50) not null,
  create_stamp timestamp(3) without time zone not null,
  last_mod_stamp timestamp(3) without time zone not null,
  optimist_lock_ver_no numeric(9,0),
  primary key(cust_no)
);

" >> tb_cddtl_cust_label.ddl
done
